﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Dln.Common.Helper;
using Dln.Model;

public partial class Page_Community_QuestionList : BasePage
{
    protected string DoctorCardId = string.Empty;
    protected string openid = string.Empty;
    protected IList<Community_Topic> CommunityTopicList = null;
    protected void Page_Load(object sender, EventArgs e)
    {
        DoctorCardId = HttpContext.Current.Request.QueryString["CardId"];
        //openid = GetAuthOpenId();
        openid = "oF6dUwxAa6BtWPqaRnE_lz7lDBgQ";

        var model = SqlHelper.Context.From<Community_Topic>().Where(d => d.openid == openid && d.DelStatus == 0);
        if (model != null && model.Count() > 0)
        {
            CommunityTopicList = model.ToList();
            foreach (var item in CommunityTopicList)
            {
                var replyModel = SqlHelper.Context.From<Community_TopicReply>().Where(d => d.ReplyId == item.Id && d.Delstatus == 0 && d.IsRead == 0);
                if (replyModel != null && replyModel.Count() > 0)
                {
                    item.Number = replyModel.Count();
                }
            }
            CommunityTopicList = CommunityTopicList.OrderByDescending(d => d.Number).ToList();
        }
    }
}